package com.lovo.bbs.servlet.admin;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lovo.bbs.bo.ForumStatBo;
import com.lovo.bbs.vo.ForumStatVo;

public class SiteUpdateServlet extends HttpServlet {

	private static final long serialVersionUID = -1544497868680865031L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse resp)
			throws ServletException, IOException {
		String msg = "OK...";
		
		ServletContext contex = request.getSession().getServletContext();
		//网站杂项信息
		ForumStatVo forumInfo =(ForumStatVo) contex.getAttribute("forumInfo");
		String content = new String(request.getParameter("content").getBytes(
				"ISO-8859-1"), "utf-8");
		if(content!=null){
			 //更新内存
			 forumInfo.setSiteNotice(content);
			 contex.setAttribute("forumInfo",forumInfo);
			 //更新数据库
			 new ForumStatBo().updateSiteNotice(content);
		}
		request.getRequestDispatcher("bulletinManageUpdatePage.jsp?msg="+msg).forward(request, resp);
	}

}
